<?php
    $menu_1 = '';
    $menu_2 = '';
    $menu_3 = '';
    $menu_4 = '';
    $menu_5 = '';
    $menu_6 = '';
    $menu_7 = '';
    $menu_8 = '';
    include('header.php');
    
    if(isset($_GET['id'])){
	$ra_id = $_GET['id'];
    }else{
	$ra_id = 0;
    }
    
    $sql = "SELECT * FROM relate_article WHERE ra_active=1 ORDER BY ra_date DESC";
    $result = $db->Execute($sql);
    $i = 0;
    $news_list = '';
    $news_detail = '';
    while (!$result->EOF)
    {
        $ra_date = date('d/m/Y',$result->fields['ra_date']);
        $class = '';
	if($result->fields['ra_id']==$ra_id){
	    $class = ' main_content_left_box_news_current';
	}else if($ra_id==0 AND ($i)==0){
	    $class = ' main_content_left_box_news_current';
	}
	
	$news_list .= <<<news_list
	    <div class="main_content_left_box_news{$class}">
		<a href="related-articles.php?id={$result->fields['ra_id']}" title="{$result->fields['ra_title']}">
		{$ra_date} {$result->fields['ra_title']}
		</a>
	    </div>
news_list;
	
	if($result->fields['ra_id']==$ra_id){
	    $msg1 = nl2br(stripslashes($result->fields['ra_msg']));
	    
	    if(img_exists(APPPATH.'/images/relate-article/'.$result->fields['ra_id'],$result->fields['ra_img'])){
		$img_rss = '<img src="'.SITEURL.'/images/relate-article/'.$result->fields['ra_id'].'/'.$result->fields['ra_img'].'" />';
	    }else{
		$img_rss = '<img src="'.SITEURL.'/images/no_img.jpg" />';
	    }
	    
	    $news_detail = '<div class="img">'.$img_rss.'</div><div class="msg">'.$msg1.'</div>';
	}else if(($i)==0){
	    $msg1 = nl2br(stripslashes($result->fields['ra_msg']));
	    
	    if(img_exists(APPPATH.'/images/relate-article/'.$result->fields['ra_id'],$result->fields['ra_img'])){
		$img_rss = '<img src="'.SITEURL.'/images/relate-article/'.$result->fields['ra_id'].'/'.$result->fields['ra_img'].'" />';
	    }else{
		$img_rss = '<img src="'.SITEURL.'/images/no_img.jpg" />';
	    }
	    
	    $news_detail = '<div class="img">'.$img_rss.'</div><div class="msg">'.$msg1.'</div>';
	}
	$i++;
        $result->MoveNext();
    }
    $result->Close();
?>
	    <div id="main_content">
		
		<div class="page_title" id="news_title">
		    <img src="images/related_title.jpg" alt="Related Articles" />
		</div>
		
		<div id="news_content_left">
		    <?php echo $news_list; ?>
		</div>
		
		<div id="news_content_right">
		    <div id="news_content_right_" class="relete_content">
			<?php echo $news_detail; ?>
			<div class="clear">&nbsp;</div>
		    </div>
		</div>
		<div class="clear">&nbsp;</div>
		
	    </div>
<?php
    include('footer.php');
?>